Skip to content

fix(cold-sql): pool starvation and query inefficiencies#45

Open
prestwich wants to merge 2 commits intomainfrom
prestwich/fix-cold-sql-pool-and-queries
Open

fix(cold-sql): pool starvation and query inefficiencies#45
prestwich wants to merge 2 commits intomainfrom
prestwich/fix-cold-sql-pool-and-queries

Conversation

@prestwich
Copy link
Copy Markdown
Member

Summary

Fixes ENG-2124

  • Pool configuration: SqlColdBackend::connect() created a single-connection pool for all backends including PostgreSQL, serializing 64 concurrent readers + 8 stream producers. Now uses per-backend defaults (SQLite: 1, PostgreSQL: 10) with acquire_timeout(5s). Adds PoolOverrides struct and SqlConnector builder for production tunability.
  • get_logs optimization: Replace COUNT(*) + SELECT with single LIMIT query — faster in both under-limit and over-limit cases.
  • get_receipt consolidation: Merge 5 sequential queries (header, receipt+tx, logs, prior gas) into 2-3 via combined JOIN with COALESCE subquery.
  • drain_above batch override: Replace default N+1 implementation (3N+7 queries) with batched single-transaction approach (9 queries regardless of block count).
  • Integer safety: Debug assertions on to_i64/from_i64, checked tx_type conversion throughout.

Test plan

  • cargo t -p signet-cold-sql --all-features — SQLite + PG conformance passing
  • cargo clippy -p signet-cold-sql --all-features --all-targets — clean
  • cargo clippy -p signet-cold-sql --no-default-features --all-targets — clean
  • cargo clippy --workspace --all-features --all-targets — clean
  • cargo +nightly fmt — clean
  • ./scripts/test-postgres.sh — PostgreSQL conformance against real database

🤖 Generated with Claude Code

prestwich added a commit to init4tech/node-components that referenced this pull request Apr 3, 2026
Update all signet-storage family crates (signet-storage, signet-cold,
signet-hot, signet-hot-mdbx, signet-cold-mdbx, signet-storage-types)
to 0.7 from init4tech/storage#45. Bump workspace version to 0.17.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich requested review from Evalir and Fraser999 April 6, 2026 16:13
- Add per-backend pool defaults and SqlConnector builder
- Add safety checks to integer conversions
- Replace get_logs COUNT+SELECT with single LIMIT query
- Consolidate get_receipt and batch drain_above
- Bump workspace version to 0.7.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@prestwich prestwich force-pushed the prestwich/fix-cold-sql-pool-and-queries branch from c4a8b9e to b513020 Compare April 6, 2026 16:15
@prestwich prestwich enabled auto-merge (squash) April 6, 2026 16:47
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant